//
//  NBAWorker.swift
//  Sports
//
//  Created by tiger on 2017/10/16.
//  Copyright © 2017年 Meigabay. All rights reserved.
//

import UIKit
import SQLite

public enum NBAWorkerGender: Int {
    case men = 1
    case women = 2
}

public enum NBAWorkerType: Int {
    case worker = 0
    case boss = 1   //球队老板
    case gm = 2     //球队经理
    case coach = 3   //教练
    case player = 4  //球员
    case referee = 5 //裁判
    case chairman = 6 //普通工作人员
}

public struct NBAWorkerCoordinate {
    var x: Double = 0
    var y: Double = 0
    
    init() {
        
    }
    
    init(x: Double,y: Double) {
        self.x = x
        self.y = y
    }
}

public class NBAWorker: NSObject {
    internal var workerId: String!
    internal var name: String! //名字
    internal var nickname: String! //绰号
    internal var gender: NBAWorkerGender! = NBAWorkerGender.men  //1男 2女
    internal var height: Double = 183 //CM
    internal var weight: Double = 75//KG
    internal var birthDay: TimeInterval! //出生
    internal var avatar: String!  //头像
    internal var drafted: TimeInterval! //进入联盟时间
    internal var introduction: String!
    internal var type: NBAWorkerType!
    
    public lazy var coordinate = NBAWorkerCoordinate()
    
    public override init() {
        super.init()
        self.workerId = String(format: "worker_%0.0f",NSDate().timeIntervalSince1970*1000)
        self.name = "工作人员"
        self.nickname = "工作人员"
        self.gender = .men
        self.height = 183
        self.weight = 75
        self.birthDay = 315547932
        self.avatar = "icon_avatar"
        self.drafted = 631167132
        self.introduction = "联赛工作人员"
        self.type = .worker
    }
    
    init(result: Row) {
        let columns = NBAWorkerTableColumn()
        self.workerId =  result[columns.workerId]
        self.name =  result[columns.name]
        self.nickname =  result[columns.nickname]
        self.gender =  NBAWorkerGender(rawValue: result[columns.gender])
        self.height =  result[columns.height]
        self.weight =  result[columns.weight]
        self.birthDay =  result[columns.birthDay]
        self.avatar =  result[columns.avatar]
        self.drafted =  result[columns.drafted]
        self.introduction =  result[columns.introduction]
        self.type =  NBAWorkerType(rawValue: result[columns.type])
    }
}
